package com.cheryjb.examples.gwt.clock.client;

import com.google.gwt.canvas.dom.client.Context2d;

/**
 * Needle Drawable Object
 * 
 * @author Jean-Baptiste Chery
 * 
 */
public class Needle extends ADrawableObject {

	/**
	 * The Needle type: hours, minutes or seconds
	 */
	private final NeedleType needleType;

	/**
	 * init the position, rotation origin point, and needle type (hours, minutes
	 * or seconds)
	 * 
	 * @param position
	 *            (x,y) vector of the images's top left corner
	 * @param needleType
	 *            hours, minutes or seconds
	 * @param rotationOrigin
	 *            (x,y) vector defining the point around which the needle is
	 *            spinning
	 */
	public Needle(final Vector position, final NeedleType needleType,
			final Vector rotationOrigin) {
		super(position, rotationOrigin);
		this.needleType = needleType;
	}

	@Override
	public void drawShapes(final Context2d context) {
		// as we use super class translation to move the object, image is always
		// drawn at (0,0)
		context.drawImage(needleType.getImage(), 0, 0);
	}

}
